package com.xiaoshuidi.cloud.framework.filings.core.enums;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 租金包含费用事项
 * @Author Feng
 * @date 2023/5/5
 */
@Getter
@AllArgsConstructor
public enum ExpenseMattersEnum {

    WATER(1,"水费"),
    ELECTRICITY(2, "电费"),
    TELEPHONE(3, "电话费"),
    TV(4, "电视收视费"),
    HEATING(5, "供暖费"),
    GAS(6, "燃气费"),
    PROPERTY_MANAGEMENT(7, "物业管理费"),
    HEALTH(8, "卫生费"),
    BROADBAND(9, "宽带费"),
    PARKING(10, "车位费"),
    IFM(11, "室内设施维修费");

    private int code;
    private String name;

    public static Integer getCodeByName(String name) {
        if (StrUtil.isEmpty(name)) {
            return null;
        }
        Optional<ExpenseMattersEnum> find = Arrays.stream(ExpenseMattersEnum.values()).filter(s -> s.getName().equals(name)).findFirst();
        if (find.isPresent()) {
            return find.get().getCode();
        }
        return null;
    }
}